//
//  OrderSubmitCell.swift
//  TrafficViolation
//
//  Created by eaglelive on 2017/5/5.
//  Copyright © 2017年 eaglelive. All rights reserved.
//

import Foundation
import UIKit
//提交订单详情页面
class OrderSubmitCell:UITableViewCell{
    let labelW:CGFloat = 60
    let labelH:CGFloat = 30
    var content,address,dateTime,money,score,service,label7:UILabel!
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCellSelectionStyle.none
        self.backgroundColor = tableBgColor
        // 背景view
        let backgroundView = UIView()
        backgroundView.layer.borderColor = colorFromHex(0xeeeeee).cgColor
        backgroundView.layer.borderWidth = 1
        backgroundView.layer.cornerRadius = 5
        backgroundView.layer.masksToBounds = true
        backgroundView.backgroundColor = UIColor.white
        self.addSubview(backgroundView)
        backgroundView.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(5)
            make.top.equalTo(self).offset(5)
            make.right.equalTo(self).offset(-5)
            make.bottom.equalTo(self)
        }
        let label1 = UILabel()
        label1.font = UIFont.systemFont(ofSize: 11)
        label1.text = "违章内容："
        backgroundView.addSubview(label1)
        label1.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(backgroundView.snp.top)
            make.left.equalTo(backgroundView.snp.left).offset(5)
            make.width.equalTo(labelW)
        }
        content = UILabel()
        content.lineBreakMode = .byTruncatingTail
        content.font = UIFont.systemFont(ofSize: 12)
        backgroundView.addSubview(content)
        content.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(backgroundView.snp.top)
            make.left.equalTo(label1.snp.right)
            make.right.equalTo(10)
        }
        let label2 = UILabel()
        label2.font = UIFont.systemFont(ofSize: 11)
        label2.text = "违章地点："
        backgroundView.addSubview(label2)
        label2.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label1.snp.bottom)
            make.left.equalTo(backgroundView.snp.left).offset(5)
            make.width.equalTo(labelW)
        }
        address = UILabel()
        address.lineBreakMode = .byTruncatingTail
        address.font = UIFont.systemFont(ofSize: 12)
        address.textColor = appMainColor
        backgroundView.addSubview(address)
        address.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label1.snp.bottom)
            make.left.equalTo(label2.snp.right)
            make.right.equalTo(10)
        }
        let label3 = UILabel()
        label3.font = UIFont.systemFont(ofSize: 11)
        label3.text = "违章时间："
        backgroundView.addSubview(label3)
        label3.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label2.snp.bottom)
            make.left.equalTo(backgroundView.snp.left).offset(5)
            make.width.equalTo(labelW)
        }
        dateTime = UILabel()
        dateTime.font = UIFont.systemFont(ofSize: 12)
        backgroundView.addSubview(dateTime)
        dateTime.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label2.snp.bottom)
            make.left.equalTo(label3.snp.right)
        }
        let label4 = UILabel()
        label4.font = UIFont.systemFont(ofSize: 11)
        label4.text = "罚款金额："
        backgroundView.addSubview(label4)
        label4.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label3.snp.bottom)
            make.left.equalTo(backgroundView.snp.left).offset(5)
            make.width.equalTo(labelW)
        }
        money = UILabel()
        money.font = UIFont.systemFont(ofSize: 12)
        backgroundView.addSubview(money)
        money.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label3.snp.bottom)
            make.left.equalTo(label4.snp.right)
        }
        
        let label5 = UILabel()
        label5.font = UIFont.systemFont(ofSize: 11)
        label5.text = "扣分情况："
        backgroundView.addSubview(label5)
        label5.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label4.snp.bottom)
            make.left.equalTo(backgroundView.snp.left).offset(5)
            make.width.equalTo(labelW)
        }
        score = UILabel()
        score.font = UIFont.systemFont(ofSize: 12)
        backgroundView.addSubview(score)
        score.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label4.snp.bottom)
            make.left.equalTo(label5.snp.right)
        }
        
        let label6 = UILabel()
        label6.font = UIFont.systemFont(ofSize: 11)
        label6.text = "服务费用："
        backgroundView.addSubview(label6)
        label6.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label5.snp.bottom)
            make.left.equalTo(backgroundView.snp.left).offset(5)
            make.width.equalTo(labelW)
        }
        service = UILabel()
        service.font = UIFont.systemFont(ofSize: 12)
        service.textColor = UIColor.red
        backgroundView.addSubview(service)
        service.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label5.snp.bottom)
            make.left.equalTo(label6.snp.right)
        }
        
        label7 = UILabel()
        label7.font = UIFont.systemFont(ofSize: 12)
        label7.textColor = appMainColor
        label7.textAlignment = .right
        backgroundView.addSubview(label7)
        label7.snp.makeConstraints { (make) in
            make.height.equalTo(labelH)
            make.top.equalTo(label6.snp.bottom)
            make.right.equalTo(self).offset(-20)
            make.width.equalTo(self)
        }
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
extension OrderSubmitCell{
    func configCellDateWithModel(model:VioInfoModel,total:Int,num:Int) {
        content.text = model.content
        address.text = model.address
        dateTime.text = model.time
        score.text = "\(model.score)分"
        money.text = "￥\(model.amount)"
        service.text = "￥\(model.samount)"
        label7.text = "\(num)/\(total)"
    }
}
